package com.jk.service;

import com.jk.dao.PersonalDataDao;
import com.jk.entity.PersonalDataEntity;
import com.jk.pojo.UserBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpSession;

/**
 * @author 位佳生
 * @title: PersonalDataService
 * @projectName springboot_financial
 * @description: TODO
 * @date 2022/11/319:22
 */
@Service
public class PersonalDataService {
    @Autowired
    private PersonalDataDao personalDataDao;

    public void personalDataSave(PersonalDataEntity personalDataEntity, HttpSession session) {
        UserBean user1 = (UserBean) session.getAttribute("user");
        PersonalDataEntity personalDataEntity1 = personalDataDao.selectById(user1.getUser_id());
        if (personalDataEntity1 !=null){
            personalDataEntity.setPersonal_data_id(user1.getUser_id());
            personalDataDao.updateById(personalDataEntity);
        }else {
            personalDataEntity.setPersonal_data_id(user1.getUser_id());
            personalDataDao.insert(personalDataEntity);
        }

    }
}
